package com.linwen.excise.niuke._80;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author wlw
 * @date 2023/3/27 11:50 PM
 */
public class _94记票统计 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Map<String, Integer> map = new LinkedHashMap<>();
        for (int i = 0; i < n; i++) {
            map.put(scanner.next(), 0);
        }
        int m = scanner.nextInt();
        int invalid = 0;
        for (int i = 0; i < m; i++) {
            String key = scanner.next();
            if(map.containsKey(key)){
                map.put(key,map.get(key)+1);
            }else{
                invalid++;
            }
        }
        map.forEach((k,v)->{
            System.out.println(k+":"+v);
        });
        System.out.println("Invalid:"+invalid);



    }
}
